import React from 'react';
import BasicLayout from "@/src/layouts";
import TopicList from "@/src/components/topicList";
import Nav from '@/src/components/nav'
class Home extends React.Component {
  constructor() {
    super();
    this.state ={
      searchKey: "",
      isSearch: false
    }
    this.changeToSearch = this.changeToSearch.bind(this);
    this.setSearched = this.setSearched.bind(this);
  }

  changeToSearch(changedSearchKey) {
    console.log("changing searchKey:");
    console.log(changedSearchKey);
    this.setState(
        {
          searchKey: changedSearchKey,
          isSearch: true,
        }
    )
  }

  setSearched(){
    this.setState({isSearch: false});
    console.log("Def setted!!");
  }

  render() {
    return (
      <BasicLayout header = {<Nav changeToSearch = {this.changeToSearch}/>}>
        <TopicList searchKey = {this.state.searchKey} isSearch = {this.state.isSearch} setSearched = {this.setSearched}/>
      </BasicLayout>
    )
  }
}

export default Home;